{extend name='admin'}
{block name='css'}
{/block}
{block name='content'}
<ul class="nav nav-tabs">
    <li role="presentation" ><a href="{:url('admin/index/index')}">首页</a></li>
    <li role="presentation" ><a href="{:url('admin/blog/index')}">博文管理</a></li>
    <li role="presentation" class="active"><a href="#">博文搜索</a></li>
</ul>
<form name="myform" id="myform" method="post">
    <table class="table table-hover">
        <tr>
            <th>标题</th>
            <th>图片</th>
            <th>所属分类</th>
            <th>作者</th>
            <th>最近更新时间</th>
            <th>点击数</th>
            <th>操作</th>
        </tr>
        {foreach $shuju as $item}
        <tr>
            <td >{$item.name}</td>
            <td>
                <img src="http://www.blog.com/{$item.image}" width="80px" alt="">
            </td>
            <td>{$item.title}</td>
            <td>{$item.author}</td>
            <td>{$item.update_time}</td>
            <td>{$item.click}</td>
            <td>
                <a class="btn btn-info link-update" href="{:url('admin/blog/blogupd?id=')}{$item.id}">修改</a>
                <a id="{$item.id}" class="btn btn-danger link-del" href="#">删除</a>
            </td>
        </tr>
        {/foreach}
    </table>
</form>
{/block}
{block name='js'}
<script>
    $(function() {
        $('.link-del').click(function () {
            var id = $(this).attr('id');
            $.ajax({
                url: "{:url('admin/blog/blogdel')}",
                type: 'get',
                data: {id: id},
                dataType: 'json',
                success: function (msg) {
                    if (msg == 1) {
                        layer.alert('删除成功', {icon: 6}, function () {
                            parent.location.reload();
                            window.location.href = "{:url('admin/blog/index')}";
                        })
                    } else {
                        layer.alert('删除失败', {icon: 5})
                    }
                }
            })
        })
    })
</script>
{/block}
{/extend}